package tw.edu.tku.im.maze;

import org.json.JSONException;
import org.json.JSONObject;

public class Bonus {
   
   int exp;
   
   //-------------------------------------------------------
   public Bonus(int exp) {
      this.exp = exp;
   }
   
   //-------------------------------------------------------
   public static Bonus parse(JSONObject jsonObj) throws JSONException {
      return new Bonus(jsonObj.getInt("exp"));
   }
   
   //-------------------------------------------------------
   public int getExp() {
      return exp;
   }
   public void setExp(int exp) {
      this.exp = exp;
   }
   
   //-------------------------------------------------------
   public String toString() {
      StringBuilder ans = new StringBuilder("{ \"exp\" : ");
      ans.append(this.exp).append(" }");
      return ans.toString();
   }
   
   //-------------------------------------------------------
   public String toJSONString() throws JSONException {
      JSONObject bonus = new JSONObject();
      bonus.put("exp", this.exp);
      return bonus.toString();
   }
}
